package ru.ifmo.filemanager.local;

import static ru.ifmo.filemanager.local.Plugin.wrap;

import java.io.File;
import java.io.IOException;

import ru.ifmo.filemanager.filesystem.abstractplugin.AbstractDirectory;
import ru.ifmo.filemanager.filesystem.interfaces.FileSystemObject;

class LocalDirectory extends AbstractDirectory {

	private final File file;

	LocalDirectory(File file) {
		this.file = file;
	}

	public String[] list() throws IOException {
		String result[] = file.list();
		if (result == null) {
			throw new IOException("Unable to read directory");
		} else {
			return result;
		}
	}

	public FileSystemObject lookup(String name) throws IOException {
		return wrap(new File(file, name));
	}

	@Override
	public String getName() {
		return file.getName();
	}
}